package com.base;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.entity.VoteType;
import com.opensymphony.xwork2.ActionSupport;
import com.service.VoteTypeService;

@SuppressWarnings("serial")
public class BaseAction extends ActionSupport {

	public HttpSession getSession(){
		return ServletActionContext.getRequest().getSession();
	}
	public ServletContext getApplication(){
		return ServletActionContext.getServletContext();
	}
	
	public String msg="";
	
	@Resource
	VoteTypeService vts;
	public List<VoteType> getAllVoteType(){
		Object obj = getApplication().getAttribute("vtlist");
		if(obj!=null){
			return (List<VoteType>) obj;
		}else{
			List<VoteType> list = vts.getAll();
			getApplication().setAttribute("vtlist", list);
			return list;
		}
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	
}
